<script type="text/javascript">

    function mycarousel_initCallback(carousel)
    {
        // Disable autoscrolling if the user clicks the prev or next button.
        carousel.buttonNext.bind('click', function() {
            carousel.startAuto(0);
        });

        carousel.buttonPrev.bind('click', function() {
            carousel.startAuto(0);
        });

        // Pause autoscrolling if the user moves with the cursor over the clip.
        carousel.clip.hover(function() {
            carousel.stopAuto();
        }, function() {
            carousel.startAuto();
        });
    }
    ;

    jQuery(document).ready(function() {
        jQuery('#mycarousel').jcarousel({
            auto: 5,
            wrap: 'last',
            initCallback: mycarousel_initCallback
        });
    });

    function mycarousel_initCallback1(carousel)
    {
        // Disable autoscrolling if the user clicks the prev or next button.
        carousel.buttonNext.bind('click', function() {
            carousel.startAuto(0);
        });

        carousel.buttonPrev.bind('click', function() {
            carousel.startAuto(0);
        });

        // Pause autoscrolling if the user moves with the cursor over the clip.
        carousel.clip.hover(function() {
            carousel.stopAuto();
        }, function() {
            carousel.startAuto();
        });
    }
    ;
    jQuery(document).ready(function() {

        jQuery('#mycarousel1').jcarousel({
            scroll: 1,
            rows: 2,
            animation: 'slow',
            auto: 3,
            wrap: 'last',
            initCallback: mycarousel_initCallback1
        });
    });
    
    
     function mycarousel_initCallback5(carousel)
    {
        // Disable autoscrolling if the user clicks the prev or next button.
        carousel.buttonNext.bind('click', function() {
            carousel.startAuto(0);
        });

        carousel.buttonPrev.bind('click', function() {
            carousel.startAuto(0);
        });

        // Pause autoscrolling if the user moves with the cursor over the clip.
        carousel.clip.hover(function() {
            carousel.stopAuto();
        }, function() {
            carousel.startAuto();
        });
    }
    ;
    jQuery(document).ready(function() {

        jQuery('#mycarousel5').jcarousel({
            scroll: 1,
            rows: 2,
            animation: 'slow',
            auto: 3,
            wrap: 'last',
            initCallback: mycarousel_initCallback5
        });
    });


    function mycarousel_initCallback2(carousel)
    {
        // Disable autoscrolling if the user clicks the prev or next button.
        carousel.buttonNext.bind('click', function() {
            carousel.startAuto(0);
        });

        carousel.buttonPrev.bind('click', function() {
            carousel.startAuto(0);
        });

        // Pause autoscrolling if the user moves with the cursor over the clip.
        carousel.clip.hover(function() {
            carousel.stopAuto();
        }, function() {
            carousel.startAuto();
        });
    }
    ;
    jQuery(document).ready(function() {

        jQuery('#mycarousel2').jcarousel({
            scroll: 1,
            rows: 2,
            animation: 'slow',
            auto: 4,
            wrap: 'last',
        
            initCallback: mycarousel_initCallback2
        });
    });
    
     function mycarousel_initCallback4(carousel)
    {
        // Disable autoscrolling if the user clicks the prev or next button.
        carousel.buttonNext.bind('click', function() {
            carousel.startAuto(0);
        });

        carousel.buttonPrev.bind('click', function() {
            carousel.startAuto(0);
        });

        // Pause autoscrolling if the user moves with the cursor over the clip.
        carousel.clip.hover(function() {
            carousel.stopAuto();
        }, function() {
            carousel.startAuto();
        });
    }
    ;
    jQuery(document).ready(function() {

        jQuery('#mycarousel4').jcarousel({
            scroll: 1,
            rows: 2,
            animation: 'slow',
            auto: 3,
            wrap: 'last',
        
            initCallback: mycarousel_initCallback4
        });
    });

</script>
<style>
    option{
        background: #d9dee2;
        color: #00335e;
    }
</style>
<div id="login-box" class="login-popup">
    <a href="#" class="close">
        <img src="<?php echo Yii::app()->request->baseUrl; ?>/css/images/close_pop.png" class="btn_close" title="Close Window" alt="Close" /></a>
    <form class="login" action="<?php echo Yii::app()->request->baseUrl; ?>/dang-nhap"  method="post">
        <h1>Đăng nhập</h1>

        <input type="email" name="txtuser" class="login-input" placeholder="Email Address" autofocus>
        <input type="password" name="txtpass" class="login-input" placeholder="Password">
        <input type="submit" value="Login" class="login-submit">

        <p class="login-help"><a href="#">Forgot password?</a></p>
    </form>
</div>


<div class="header">
    <div id="head" class="headerBg">

        <div class="headerWidth">
            <div style="width: 100%">
                <div style="float: left; margin-right: 20px">
                    <a href="<?php echo Yii::app()->request->baseUrl; ?>/" title="Chợ mới,chomoionline, nơi kết nối muôn vàn trái tim người tiêu dùng">
                        <img src="<?php echo Yii::app()->request->baseUrl; ?>/css/images/logo_gmt.png" style="margin-top: 2px" alt="chợ mới, chomoionline.com, đăng tin quảng cáo"/>
                    </a>
                </div>
                <div style="float: left; width: 212px; ">
                    <div id='cssmenu'>
                        <ul>

                            <li class='has-sub'><a href='<?php echo Yii::app()->request->baseUrl; ?>/page/gioi-thieu'><span>Giới thiệu</span></a>

                            </li>
                            <li class='has-sub'><a href='<?php echo Yii::app()->request->baseUrl; ?>/page/quy-che'><span>Quy chế</span></a>


                            </li>


                            <li class='has-sub'><a href='<?php echo Yii::app()->request->baseUrl; ?>/page/lien-he/'><span>Liên hệ</span></a>

                            </li>
                        </ul>
                    </div>
                </div>
                <div style="float:left;width: 300px">
                    <div class="searbox">
                        <form action="<?php echo Yii::app()->request->baseUrl; ?>/tim-luat-su" method="post">

                            <div style="float:left;margin-left: 10px;">
                                <img src="<?php echo Yii::app()->request->baseUrl; ?>/icon/bg_location.png" style="margin-left: 10px;margin-top: 5px">
                            </div>
                            <div style="float: left; z-index: 9;">


                                <?php
                                $models = Doanluatsu::model()->findAll();
                                if (isset(Yii::app()->request->cookies['idoanluat']->value)) {
                                    $cityID = Yii::app()->request->cookies['idoanluat']->value;
                                } else {
                                    $cityID = 30;
                                }
                                $list = CHtml::listData($models, 'id', 'name');
                                echo CHtml::dropDownList('id', '', $list, array(
                                    'style' => 'width: 170px;background:#DED6BD;border: 0px; color:#4B4B4B;font-size: 12px;font-weight: 600;',
                                    //'prompt' => 'Chọn tỉnh/thành',
                                    'options' => array($cityID => array('selected' => true)),
                                    //'ajax' => array(
                                    //'type' => 'POST', //request type
                                    //'url' => CController::createUrl('site/dynamiccities'), //url to call.
                                    //'update' => '#disID', //selector to update
                                    //'data' => array('cityID' => 'js:this.value'),
                                    'onchange' => 'document.location.href = "' . Yii::app()->request->baseUrl . '/tim-luat-su/" + this.value',
                                        //)
                                ));
                                ?>
                            </div>
                            <div id='search' style="float: left; margin-left: -45px; z-index: 10">
                                <input type="text" name="key" placeholder="nhập từ khóa..." style="width: 218px; height: 29px"> 
                            </div>

                        </form>
                    </div>
                </div>
                <div style="float: right;width: 192px">

                    <div style="float: left; padding-top: 15px">

                        <?php
                        $session = new CHttpSession;
                        $session->open();
//$value1 = $session['user_salesmart'];
//if (Yii::app()->session->contains('userlogin')) {
// $model = Yii::app()->session->get('userlogin');
// $em = ' '.$model->email;
// echo $em;
// }
// session_start();

                        if (isset($session['user_salesmart'])) {

                            $ten0 = $session['user_salesmart'][2];
                            $list = explode(" ", $ten0);
                            $cout = count($list);
                            $ten = $list[$cout - 1];
                            $i = strlen($ten);
                            if ($i > 9) {
                                $ten = substr($ten, -9);
                            } else if ($i === 7) {
                                $ten = $ten . '...';
                            } else if ($i === 6) {
                                $ten = $ten . '....';
                            } else if ($i < 6) {
                                $ten = $ten . '.....';
                            }

                            //echo '<div id="linkwap"><a href="#">' . $session['user_salesmart'][0] . '</a></div>';
                            //echo '<div id="canhan" style="margin-right: 5px"><a style="text-decoration: none; color: white" href="' . Yii::app()->request->baseUrl . '/ca-nhan" ><img src="' . Yii::app()->request->baseUrl . '/icon/user.png">Tài khoản: ' . $ten . '</a></div>';
                            ?>

                            <link rel='stylesheet' type='text/css' href='<?php echo Yii::app()->request->baseUrl; ?>/js/menuAcount/menuTemplate3.css' />

                            <script type='text/javascript' src='<?php echo Yii::app()->request->baseUrl; ?>/js/menuAcount/centerAlign.js'></script>
                            <ul class="menuTemplate3 decor3_1" license="mylicense" style="background: #DED6BD;">
                                <li><a href="#Web-Menus" class="arrow" style="background: #DED6BD;"><?php echo $ten; ?></a>
                                    <div class="drop decor3_2 dropToLeft" style="width: 100px;">


                                        <div class='left'>
                                            <b><a href="<?php echo Yii::app()->request->baseUrl; ?>/ca-nhan">Tài khoản</a><br /></b>


                                            <b> <a href="<?php echo Yii::app()->request->baseUrl; ?>/thoat-he-thong">Thoát</a><br /></b>

                                        </div>
                                    </div>
                                </li>
                            </ul>
                            <?php
                        } else {
                            echo '<a id="login" href="#login-box" class="login-window" >Đăng nhập</a>';

                            // session_destroy();
                            $a = Yii::app()->controller->id;
                            $p = Yii::app()->controller->action->id;
                            if ($a === 'manager' && $p != 'dangky' && $p!='Addlienhels' && $p!='Addlienheqc') {
                                $this->redirect('http://luatsukhongbiengioi.org/');
                            }
                            
                        }
                        ?>
                    </div>
                    <div style="float: left; padding-top: 15px; margin-right: 26px">
                        <?php
                        if (!isset($session['user_salesmart'])) {
                            echo '<a id="dk" href = "' . Yii::app()->request->baseUrl . '/dang-ky" >Đăng ký</a>';
                        }
                        ?>
                    </div>


                </div>

                <div style="clear: both"></div>

            </div>
        </div>
       
    </div>

</div>
